<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title> 智慧担保- 主页</title>

    <meta name="keywords" content="">
    <meta name="description" content="">

    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->

    <!--<link rel="shortcut icon" href="img/favicon.ico">-->
    <link rel="stylesheet" href="css/BeAlert.css">
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/plugins/jqgrid/ui.jqgrid.css?0820" rel="stylesheet">
    <link href="css/plugins/toastr/toastr.min.css" rel="stylesheet">
    <link href="css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
    <link href="css/plugins/webuploader/webuploader.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="css/demo/webuploader-demo.css">
    <link href="css/plugins/steps/jquery.steps.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <link href="css/plugins/timepicker/jquery-timepicker.css" rel="stylesheet">
    <link href="css/plugins/clockpicker/clockpicker.css" rel="stylesheet">
    <link href="css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <!--<link href="css/plugins/morris/morris-0.4.3.min.css" rel="stylesheet">-->
    <script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js?id=K3OQvpa2IS708Qv5&ck=K3OQvpa2IS708Qv5"></script>
</head>

<body class="fixed-sidebar full-height-layout gray-bg" style="overflow:hidden">
<div class="my-loading" style="display: none">
    <div class="sk-spinner sk-spinner-wave" style="margin-top: 30%;">
        <div class="sk-rect1"></div>
        <div class="sk-rect2"></div>
        <div class="sk-rect3"></div>
        <div class="sk-rect4"></div>
        <div class="sk-rect5"></div>
    </div>
</div>
<div id="wrapper">
    <!--左侧导航开始-->
    <nav class="navbar-default navbar-static-side" role="navigation">
        <div class="nav-close"><i class="fa fa-times-circle"></i>
        </div>
        <div class="sidebar-collapse">
            <ul class="nav" id="side-menu">
                <li class="nav-header">
                    <div class="dropdown profile-element">
                        <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                                <span class="clear">
                                    <span class="block m-t-xs" style="font-size:20px;">
                                        <i class="fa fa-bug"></i>
                                        <strong class="font-bold">智慧担保</strong>
                                        <img :src="logoUrl">
                                    </span>
                                </span>
                        </a>
                    </div>
                    <div class="logo-element">调查
                    </div>
                </li>
                <li class="line dk"></li>
                <li class="hidden-folded padder m-t m-b-sm text-muted text-xs">
                </li>
                <li>
                    <a class="J_menuItem" :href="applicationContextRootPath + 'index.html'"
                       data-pjax>
                        <i class="fa fa-home"></i>
                        <span class="nav-label">主页</span>
                    </a>
                </li>
                <li v-for="item in tops">
                    <a href="#">
                        <i :class="item.icon"></i>
                        <span class="nav-label">{{item.name}}</span>
                        <span class="fa arrow"></span>
                    </a>
                    <ul class="nav nav-second-level">
                        <li v-for="sub in subs">
                            <a class="J_menuItem" :href="menuUrl(sub)"
                               v-if="sub.parentId === item.menuId"
                               data-pjax>{{sub.name}}</a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </nav>
    <!--左侧导航结束-->
    <!--右侧部分开始-->
    <div id="page-wrapper" class="gray-bg dashbard-1">
        <div class="row border-bottom">
            <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0;">
                <div class="navbar-header"><a class="navbar-minimalize minimalize-styl-2 btn btn-info " href="#"><i
                        class="fa fa-bars"></i> </a>
                    <form role="search" class="navbar-form-custom" method="post" action="search_results.html">
                        <div class="form-group">
                            <input type="text" placeholder="请输入您需要查找的内容 …" class="form-control" name="top-search"
                                   id="top-search">
                        </div>
                    </form>
                </div>
                <!--                <div style="float: right;margin-right: 1%;margin-top: 1%;">-->
                <!--                    <a class="alert-link" v-on:click="logout()"> 登出</a>-->
                <!--                    <a class="alert-link" > 修改密码</a>-->
                <!--                </div>-->
                <div class="top-nav ">
                    <!--search & user info start-->
                    <ul class="nav pull-right top-menu">
                        <!-- user login dropdown start-->
                        <li class="dropdown" style="display: inline-block !important;  margin-right: 40px">
                            <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                                <img alt="" :src="profile.avatar" class="img-circle" style="max-width: 20%;">
                                <span class="username">{{user ? user.username : '未登录'}} {{user.companyName ? '('+ user.companyName +')' : ''}}</span>
                                <b class="caret"></b>
                            </a>
                            <ul class="dropdown-menu extended logout">
                                <div class="log-arrow-up"></div>
                                <li><a v-on:click="doRealname()"><i class="icon-bell-alt"></i> 实名认证</a></li>
                                <li><a v-on:click="editPwd()"><i class="icon-bell-alt"></i> 修改密码</a></li>
                                <li><a v-on:click="logout()"><i class="icon-key"></i> 注销登陆</a></li>
                            </ul>
                        </li>
                        <!-- user login dropdown end -->
                    </ul>
                    <!--search & user info end-->
                </div>
            </nav>

        </div>
        <div class="row J_mainContent page-container" id="content-main">

        </div>
    </div>
    <!--右侧部分结束-->
</div>

<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/plugins/echarts/echarts-all.js"></script>
<script src="js/jquery.pjax.js"></script>
<script src="js/BeAlert.js"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>
<!-- Peity -->
<script src="js/plugins/peity/jquery.peity.min.js"></script>

<!-- jqGrid -->
<!--<script src="js/plugins/jqgrid/i18n/grid.locale-cn.js?0820"></script>-->
<!--<script src="js/plugins/jqgrid/jquery.jqGrid.min.js?0820"></script>-->
<script src="js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="js/plugins/layer/layer.min.js"></script>
<script src="js/vue.js"></script>
<script src="js/vue-plus.js"></script>
<!-- 自定义js -->
<script src="js/hAdmin.js?v=4.1.0"></script>
<!-- 第三方插件 -->
<script src="js/plugins/pace/pace.min.js"></script>
<script src="js/ajax-util.js"></script>
<script src="js/plugins/validate/jquery.validate.min.js"></script>
<script src="js/plugins/validate/messages_zh.min.js"></script>
<script src="js/plugins/toastr/toastr.min.js"></script>
<script src="js/jquery-ui-1.10.4.min.js"></script>
<script src="js/plugins/beautifyhtml/beautifyhtml.js"></script>
<script src="js/plugins/webuploader/webuploader.min.js"></script>
<script src="js/plugins/datapicker/bootstrap-datepicker.js"></script>
<!-- Morris -->
<script src="js/plugins/morris/raphael-2.1.0.min.js"></script>
<script src="js/plugins/morris/morris.js"></script>
<!-- 自定义js -->
<script src="js/content.js?v=1.0.0"></script>
<script src="js/Sortable.js"></script>
<script src="js/jquery.json.js"></script>
<script src="js/pageination.js"></script>
<script src="js/monitor.js"></script>
<script src="js/plugins/staps/jquery.steps.min.js"></script>
<script src="js/plugins/timepicker/jquery-timepicker.js"></script>
<script type="text/javascript" src="js/plugins/daterangepicker/moment.min.js"></script>
<script type="text/javascript" src="js/plugins/daterangepicker/daterangepicker.js"></script>
<script type="text/javascript" src="js/plugins/prettyfile/bootstrap-prettyfile.js"></script>
<script src="js/plugins/clockpicker.js"></script>


<script>
    currentVue = null;
    let mediaUtil
    let pcmBuffer = []
    let speakersList = []

    $(document).pjax('[data-pjax] a, a[data-pjax]', '.page-container');
    // $.jgrid.defaults.styleUI = 'Bootstrap';
    var mvm = new Vue({
        el: '#wrapper',
        data: {
            profile: {},
            notifies: [],
            applicationContextRootPath: '/',
            tops: [],
            subs: [],
            master: [],//用于存储权限数组
            logoUrl: '',
            user: {username: '', phone: '', userid: '', password: '', idNum: ""},//存储username查取其参与考试
        },
        created: function () {
            this.loadTops();
            this.loadSubs();
            this.loadMaster();
            this.loadProfile();
            this.loadPermit();
        },
        methods: {
            menuUrl(sub) {
                if(sub.url.startsWith("/")) {
                    return  sub.url;
                }
                return this.applicationContextRootPath + sub.url
            },
            toNotice() {
                toPage("pages/notice/index.html");
            },
            loadPermit() {
                AJAX.GET('/auth/session/me', {}, function (resp) {
                    sessionStorage.setItem('permits', JSON.stringify(resp));
                })
            },
            loadProfile() {
                let that = this;
                AJAX.GET('profile', {}, function (resp) {
                    that.profile = resp.data;
                });
            },
            loadLogoUrl() {
                let that = this;
                AJAX.GET("args/logo", {
                    code: window.location.host
                }, function (resp) {
                    let d = resp.data;
                    if (d) {
                        that.logoUrl = d.value + sessionStorage.getItem('access_token');
                    }
                })
            },
            loadTops: function () {
                let that = this;
                AJAX.GET("/api/sysMenu/top", {}, function (resp) {
                    that.tops = resp.data;
                });
            },
            loadSubs: function () {
                let that = this;
                AJAX.GET("/api/sysMenu/sub", {}, function (resp) {
                    that.subs = resp.data;
                });
            },
            loadMaster: function () {
                let that = this;
                AJAX.GET("/auth/session/info", {}, function (resp) {
                    that.master = resp.data.authorities;
                    that.user.username = resp.data.principal.sysUser.username;
                    that.user.phone = resp.data.principal.sysUser.mobile;
                    that.user.userid = resp.data.principal.sysUser.uid;
                    that.user.password = resp.data.principal.sysUser.password;
                    that.user.idNum = resp.data.principal.sysUser.idNum;
                    that.user.companyName = resp.data.principal.sysUser.company ? resp.data.principal.sysUser.company.name : "";
                    sessionStorage.setItem('user', JSON.stringify(that.user));
                    sessionStorage.setItem('master', JSON.stringify(that.master));
                });
            },
            sidebarClick: function (e) {
                $('.sidebar-link').removeClass('active');
                $(e.srcElement).addClass('active');
            },
            collapseMenu: function (e) {
                if ($(e.srcElement).next().hasClass('show')) {
                    $(e.srcElement).next().removeClass('show');
                } else {
                    $(e.srcElement).next().addClass('show');
                }
            },
            logout: function () {
                confirm("您确定要登出吗?", "", function (isConfirm) {
                    if (isConfirm) {
                        sessionStorage.clear();
                        window.location.href = "/login?redirect_url=/";
                    } else {
                        //after click the cancel
                    }
                }, {confirmButtonText: '确认', cancelButtonText: '取消', width: 400});

            },
            editPwd: function () {
                $.pjax({
                    url: mvm.applicationContextRootPath + 'pages/editPwd.html',
                    container: '.page-container'
                });
            },
            doRealname() {
                location.href = "/realname"
            }
        }
    });
    const currentPage = sessionStorage.getItem('currentPage');
    $.pjax({
        url: currentPage ? currentPage : mvm.applicationContextRootPath + 'pages/home.html',
        container: '.page-container'
    });


    $(document).ajaxError(function (e, xhr, opt) {
        if (xhr.status == 401) {
            // location.href = 'http://' + window.location.host + '/login?redirect_url=/survey/';
        }
    });
    $(document).ajaxStart(function (XMLHttpRequest) {
        // console.log(XMLHttpRequest)
    })

    $(document).on("keypress", ".search-input", function (ev) {
        if (event.keyCode == 13) {
            $(this).parent().find('button').click();
        }
    });

    $(document).on('pjax:start', function () {
    })

</script>
</body>

</html>
